package com.qian.apiserver.service;

import com.qian.apiserver.model.Warn;
import com.qian.apiserver.entity.GmWarn;
import com.qian.apiserver.dao.WarnDao;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.service.common.BaseRepository;
import java.lang.String;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;
import com.qian.apiserver.service.IWarnService;

public abstract class WarnServiceBase extends BaseServiceImpl<Warn, GmWarn, Integer> implements IWarnService {

	@Autowired
	private WarnDao dao;

	@Override protected WarnDao getDao() {
	return dao;
	}

	@Override
	protected Warn entity2model(GmWarn entity) {
		Warn model = null;
		if(isNotEmpty(entity)){
			model = new Warn();
			model.setId(entity.getId());
			model.setWarnType(entity.getWarnType());
			model.setWarnContent(entity.getWarnContent());
		}
		return model;
	}

	@Override
	protected GmWarn model2Entity(Warn model) {
		GmWarn entity = null;
		if(isNotEmpty(model)){
			entity = new GmWarn();
			entity.setId(model.getId());
			entity.setWarnType(model.getWarnType());
			entity.setWarnContent(model.getWarnContent());
		}
		return entity;
	}

	@Override
	protected GmWarn updateParams(Warn model) {
		GmWarn entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getWarnType()))
			entity.setWarnType(model.getWarnType());
		if(isNotEmpty(model.getWarnContent()))
			entity.setWarnContent(model.getWarnContent());
		return entity;
	}


}